// task22.cpp: 定义控制台应用程序的入口点。
//

#include "stdafx.h"


#include <iostream>
#include <string>
using namespace std;

class student
{
public:
	student()
	{
		no = -1;
		name = "无名氏.";
	}

	void set()
	{
		cout << "请输入学生学号.";
		cin >> no;
		cout << "请输入学生姓名.";
		cin >> name;
	}

	void show()
	{
		cout << "学生学号为:" << no << endl;
		cout << "学生姓名为：" << name << endl;
	}
private:
	int no;
	string name;
};

class Class
{
public:
	Class()
	{
		name = "class.";
		number = 0;
		p = NULL;
	}

	Class(string na, int a, student* b)
	{
		name = na;
		number = a;
		p = b;
	}

	void show()
	{
		for (int i = 0; i < number; i++)
		{
			p[i].show();
		}

	}

	~Class()
	{
		delete[]p;
	}
private:
	string name;
	int number;
	student *p;
};

Class *chuang()
{
	int i;
	student *a;
	a = new student[5];
	for (i = 0; i < 5; i++)
	{
		(a + i)->set();
	}
	for (i = 0; i < 5; i++)
	{
		(a + i)->show();

	}
	Class* shumei = new Class("数字媒体161.", 5, a);


	return shumei;
}

int main()
{
	Class *c = chuang();

	c->show();

	return 0;
}


